#include "wds_sounds.h"

const std::string WDSSounds::MUSIC_MENU = "sounds/mat_music_menu.ogg";
const std::string WDSSounds::MUSIC_INGAME = "sounds/mat_music_ingame.ogg";	

WDSSounds::WDSSounds()					
{
	for(int i = 0; i < SOUND_NAMES_C; i++)
	{
		m_PlayCounters[i] = 0;
	}
}

WDSSounds&	WDSSounds::Instance()
{
	static WDSSounds	Inst;
	return Inst;
}

void		WDSSounds::PlayMusic(const std::string& Name)
{
	AUDIO().PlayMusic(Name);

}

void		WDSSounds::PlaySoundSFX(SOUND_NAMES SFXEnum)
{
	m_PlayCounters[(int)SFXEnum] = 0.001f;
	
}

void		WDSSounds::Tick(float dt)
{
	for(int i = 0; i < SOUND_NAMES_C; i++)
	{
		if( m_PlayCounters[i] > 0)
		{
			m_PlayCounters[i] -= dt;
			if(m_PlayCounters[i] <= 0)
			{
				InternalPlay((WDSSounds::SOUND_NAMES)i);
			}
		}
	}	
}


void		WDSSounds::InternalPlay(SOUND_NAMES SFXEnum)
{
	switch(SFXEnum)
	{
		case SFX_NONE:
		break;

		case SFX_GUN_RELOAD:
			AUDIO().PlayEvent("gun_reload");
		break;		

		case UI_CLICK:
			break;

		case UI_POPUP:
			AUDIO().PlayEvent("popup_open");
			break;

		case UI_SCORE_TICK:
			AUDIO().PlayEvent("ui_score_tick");		
			break;	
			
		case SOUND_NAMES_C:
			break;		

		default:
			break;

	}
}

